package com.gsafety.wellsfort.domain.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.gsafety.wellsfort.common.enums.CustomerTypeEnum;
import com.gsafety.wellsfort.domain.model.knowledge.TeachingAid;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Data
public class TeachingAidVO {
    private Integer id;

    @ApiModelProperty(value = "教具对象值")
    private Integer objectType;
    @ApiModelProperty(value = "教具对象文本")
    private String objectTypeText;

    @ApiModelProperty(value = "教具名称")
    private String name;

    @ApiModelProperty(value = "型号")
    private String model;

    @ApiModelProperty(value = "数量")
    private Integer quantity;

    @ApiModelProperty(value = "价格")
    private BigDecimal price;

    @ApiModelProperty(value = "用途")
    private String usage;

    @ApiModelProperty(value = "启用禁用")
    private Byte isOpen;

    private Integer creator;
    @ApiModelProperty(value = "添加人名字")
    private String creatorName;


    @ApiModelProperty(value = "添加时间")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;


    private Integer modified;
    @ApiModelProperty(value = "修改人字")
    private String modifiedName;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;
    @ApiModelProperty(value = "教具权限")
    private List<TeachaidPrivilegeVO> teachaidPrivilege;

    public static class VOBuilder {
        TeachingAid teachingAid;
        TeachingAidVO teachingAidVO = new TeachingAidVO();

        public VOBuilder(TeachingAid q) {
            this.teachingAid = q;
        }

        public TeachingAidVO build() {
            BeanUtils.copyProperties(teachingAid, teachingAidVO);
            teachingAidVO.setObjectTypeText(teachingAidVO.getObjectType() == null ? "" : CustomerTypeEnum.parseVal(teachingAidVO.getObjectType()).label);
            return teachingAidVO;
        }
    }
}
